home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Jumpstart / Multimedia Microsoft Jumpstart Version 1.1a (Microsoft).BIN / develpmt / sdk / vfw11.win / vfwdk / flat.as_ / flat.bin
Encoding:
Text File  |  1993-11-19  |  4.5 KB  |  154 lines

  1.         TITLE FLAT.ASM
  2.         page 60,132
  3.  
  4. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5. ;
  6. ; FLAT.ASM - Returns a selector to the frame buffer memory
  7. ;
  8. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  9. ;
  10. ;   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  11. ;   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  12. ;   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  13. ;   PURPOSE.
  14. ;
  15. ;   Copyright (c) 1992, 1993  Microsoft Corporation.  All Rights Reserved.
  16. ;
  17. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  18.  
  19.  
  20. ?PLM=1        ; PASCAL Calling convention is DEFAULT
  21. ?WIN=0      ; Windows calling convention
  22.  
  23.         .286
  24.         .xlist
  25.         include cmacros.inc
  26.         include vcap.inc
  27.         .list
  28.  
  29.         externFP    AllocSelector           ; in KERNEL
  30.         externFP    FreeSelector            ; in KERNEL
  31.         externFP    SetSelectorBase         ; in KERNEL
  32.         externFP    SetSelectorLimit        ; in KERNEL
  33.  
  34. public CreatePhysicalSelector
  35.  
  36. ; -------------------------------------------------------
  37. ;               DATA SEGMENT DECLARATIONS
  38. ; -------------------------------------------------------
  39.  
  40. ifndef SEGNAME
  41.         SEGNAME equ <_TEXT>
  42. endif
  43.  
  44. createSeg %SEGNAME, CodeSeg, word, public, CODE
  45.  
  46. sBegin Data
  47.         GlobalD         glpFrameBuffer, 0
  48. sEnd Data
  49.  
  50. sBegin CodeSeg
  51.         assumes cs,CodeSeg
  52.         assumes ds,Data
  53.         assumes es,nothing
  54.  
  55. ;----------------------------------------------------------------
  56. ;
  57. ;   returns DX:AX       --> selector:offset to video buffer
  58. ;
  59. ;----------------------------------------------------------------
  60.         assumes ds,Data
  61.         assumes es,nothing
  62.  
  63. cProc CreatePhysicalSelector,<FAR,PASCAL,PUBLIC>,<si,di>
  64.         ParmD   base
  65.         ParmD   limit
  66. cBegin
  67.         mov     cx,base.lo      ; BX:CX = physical base of memory
  68.         mov     bx,base.hi
  69.  
  70.         mov     di,limit.lo     ; SI:DI = extent of memory
  71.         mov     si,limit.hi
  72.  
  73.         mov     ax,0800h        ; call DPMI
  74.         int     31h
  75.         jnc     dpmi_no_error
  76.  
  77. dpmi_error:
  78.         xor     si,si
  79.         jmp     exit
  80.  
  81. dpmi_no_error:                  ; BX:CX contains linear base
  82.         mov     di,cx           ; save it in SI:DI
  83.         mov     si,bx
  84.  
  85.         ;
  86.         ;   now create a selector that points to the memory
  87.         ;
  88.         cCall   AllocSelector, <ds>
  89.         xchg    si,ax               ; si = selector, ax = base.hi
  90.  
  91.         cCall   SetSelectorBase,<si, ax, di>
  92.  
  93.         ;we should be able to use the following, but for some
  94.         ;reason, Kernel limits size to only 1 Meg.
  95.         ;Therefore, call DPMI directly to set the size!!!
  96.         ;cCall   SetSelectorLimit,<si, limit>  ; doesn't work > 1 Meg.
  97.  
  98.         mov     ax,0008h        ; call SetSegmentLimit
  99.         mov     bx,si           ; selector in bx
  100.         mov     cx,limit.hi     ; CX:DX = physical extent of memory
  101.         mov     dx,limit.lo
  102.         int     31h
  103. exit:
  104.         mov     dx,si           ; DX:AX points to memory
  105.         xor     ax,ax
  106. cEnd
  107.  
  108.  
  109. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  110. ; GetFrameBufferPointer     Gets a linear pointer to frame memory.
  111. ;
  112. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  113.  
  114. cProc GetFrameBufferPointer,<FAR,PASCAL,PUBLIC,WIN>,<si,di>
  115.         ParmB        bAddress        ; bAddress is (1-14)
  116. cBegin
  117.     ; Get a selector to display memory
  118.     xor    ax, ax
  119.     xor    bx, bx
  120.     mov    bl, bAddress
  121.     mov    cl, 04h
  122.     shl    bx, cl
  123.     mov    cx, 0010h
  124.         ; (1 Meg - 1) (must change following for larger buffer sizes)
  125.     cCall    CreatePhysicalSelector,<bx,ax,000Fh,0FFFFh>
  126.         mov     glpFrameBuffer.sel, dx
  127.         mov     glpFrameBuffer.off, ax  
  128. cEnd
  129.  
  130. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  131. ; FreeFrameBufferSelector
  132. ;
  133. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  134.  
  135. cProc FreeFrameBufferSelector,<FAR,PASCAL,PUBLIC,WIN>,<si,di>
  136. cBegin
  137.         ; Free the selector after setting its length to zero.
  138.         mov     ax, glpFrameBuffer.sel
  139.         or      ax,ax
  140.         jz      NoSelector
  141.         mov     bx, ax          ; BX is the selector
  142.         mov     ax,0008h        ; call SetSegmentLimit
  143.         xor     cx,cx           ; CX:DX = physical extent of memory
  144.         xor     dx,dx
  145.         int     31h
  146.  
  147.         cCall   FreeSelector, <bx>
  148. NoSelector:
  149.         xor     ax,ax
  150. cEnd
  151.  
  152. sEnd
  153. end
  154.